<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<style type="text/css">
			#scanview{
				width: 100%;
				position: absolute;
				top: 0px;
				bottom: 135px;
				text-align: center;
			}
			.tip{
				font-weight: bold;
				color: #FFFFFF;
				text-shadow: 0px -1px #103e5c;
			}
			footer{
				width: 100%;
				position: absolute;
				bottom: 0px;
				text-align: center;
				color: #FFFFFF;
			}
		</style>
	</head>

	<body style="background-color: #000000;">
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript">
			mui.init({
				
			});
			var ws = null,wo = null;
			var scan = null,domready = null;
			function plusReady(){
				if(ws || !window.plus || !domready){
					return;
				}
				//获取对象窗口
				var ws = plus.webview.currentWebview();
				var wo = ws.opener();
				//开始扫描
				ws.addEventListener('show',function(){
					scan = new plus.barcode.Barcode('scanview');
					scan.onmarked = onmarked;
					scan.start({conserve:true,filename:"_nocode/barcode/"});
				});
				//显示页面并关闭等待框
				ws.show('pop-in');
				wo.evalJS('closeWaiting()');
			}
				//监听window加载事件
				if(window.plus){
					plusReady();
				}else{
					document.addEventListener('plusready',plusReady,false);
				}
				//监听domcontentonloaded加载事件
				document.addEventListener('DOMContentLoaded',function(){
					domready = true;
					plusReady();
				});
				//二维码扫描成功
				function onmarked(type,code,file){
					switch(type){
						case plus.barcode.QR:
						type = "QR";
						break;
						case plus.barcode.EAN13:
						type = "EAN13";
						break;
						case plus.barcode.EAN8:
						type = "EAN8";
						break;
						default:
						type = '其他'+type;
						break;
					}
					code = code.replace(/\n/g,'');
					plus.runtime.openURL(code,function(){
						back();
					});
					back();
				}
		</script>
		<div id="scanview">
			<div style="height: 40%"></div>
			<p class="tip">...载入中...</p>
		</div>
		<footer>
			<div onclick="scanImg()" class="mui-btn mui-btn-success mui-btn-block">
				码包
			</div>
			<div onclick="back()" class="mui-btn mui-btn-block mui-btn-danger">
				取消
			</div>
		</footer>
	</body>

</html>